package mapred.config;

import mapred.task.AbstractReducer;
import mapred.task.extention.DirectReducer;

@SuppressWarnings("unchecked")
public class ReduceConfig {

    private Class<? extends AbstractReducer> reducerClass;

    private int numReduceTasks;

    private ReduceConfig(
            Class<? extends AbstractReducer> reducerClass,
            int numReduceTasks) {
        if (reducerClass == null) {
            this.reducerClass = DirectReducer.class;
        } else {
            this.reducerClass = reducerClass;
        }
        this.numReduceTasks = numReduceTasks;
    }

    public static ReduceConfig newInstance(
            Class<? extends AbstractReducer> reducerClass,
            int numReduceTasks) {
        return new ReduceConfig(reducerClass, numReduceTasks);
    }

    public Class<? extends AbstractReducer> getReducerClass() {
        return reducerClass;
    }

    public int getNumReduceTasks() {
        return numReduceTasks;
    }

}
